package com.shangcheng.service;

import com.shangcheng.entity.TProduct;
import com.shangcheng.mapper.TProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class ProductServiceImpl {
    @Autowired
    private TProductMapper productDao;
    @Transactional
    public TProduct addProduct(TProduct product) {
        productDao.insert(product);
        return product;
    }

    @Transactional(readOnly = true)
    public List<TProduct> allProducts() {
        return productDao.selectList(null);
    }
}
